/*用户管理文件接口 */
import request from '@/utils/request.js'
import { MenuParams, PermisstionList, ReqGetPermissionResponseData } from './type.js'
enum API {
  GetPermission_URL = '/admin/acl/permission',
  FindRoleIdOnPermission_URL = '/admin/acl/permission/toAssign/',
  AssignRolePermission_URL = '/admin/acl/permission/doAssign/?',
  AddPermission_URL = '/admin/acl/permission/save',
  UpdataPermission_URL = '/admin/acl/permission/update',
  DelPermission_URL = '/admin/acl/permission/remove/'
}

export const reqGetPermission = () =>
  request.get<any, ReqGetPermissionResponseData>(API.GetPermission_URL)

export const reqFindRoleIdOnPermission = (roleId: number) =>
  request.get<any, ReqGetPermissionResponseData>(API.FindRoleIdOnPermission_URL + `${roleId}`)

export const reqAssignRolePermission = (roleId: number, permissionId: any) =>
  request.post<any, ReqGetPermissionResponseData>(
    API.AssignRolePermission_URL + `roleId=${roleId}&permissionId=${permissionId}`
  )
export const reqAddPermission = (permission: MenuParams) =>
  request.post<any, any>(API.AddPermission_URL, permission)
export const reqUpdataPermisstion = (permission: MenuParams) =>
  request.put<any, any>(API.UpdataPermission_URL, permission)
export const reqDelPermission = (id: number) =>
  request.delete<any, any>(API.DelPermission_URL + `${id}`)
